package leetcode;

/**
 * 描述:53. 最大子数组和
 *
 * @author Madison You
 * @created 1:52
 */
public class Easy_53_MaxSubArray {

    public static void main(String[] args) {

    }

    public int maxSubArray(int[] nums) {
        int pre = 0, maxAns = nums[0];
        for (int x : nums) {
            pre = Math.max(pre + x, x);
            maxAns = Math.max(maxAns, pre);
        }
        return maxAns;
    }

}
